package com.ruiysoft.website.mapper;

import com.ruiysoft.website.dto.CmsContentEx;
import com.ruiysoft.website.entity.CmsContent;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Yanghu
 * @since 2019-04-29
 */
public interface CmsContentMapper extends BaseMapper<CmsContent> {
    @Select("<script>" +
            "select catalog.`name` as cataLogName, content.* " +
            "from cms_content as content " +
            "left join cms_catalog as catalog on content.catalogCode = catalog.`code` and catalog.enterpriseId = #{enterpriseId} " +
            "where content.enterpriseId = #{enterpriseId} <if test='catalogCode != null'>and content.catalogCode = #{catalogCode}</if>" +
            "ORDER BY catalogCode desc" +
            "</script>")
    List<CmsContentEx> selectLeftJoinCatalog(@Param("enterpriseId") Integer arg0, @Param("catalogCode") String arg1);

}
